<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>web socket</title>
  </head>
  <body>
    <button class="btn">发送消息</button>
    <script src="./webSocket.js"></script>
    <script>
      // 1. 连接上ws服务器
      const socket = initWebSocket("ws://localhost:3000");

      // // 2. 给服务器发送消息
      // document.querySelector(".btn").onclick = function () {
      //   socket.send("hello ws~");
      // };

      // // 3. 接受服务器的消息
      // socket.onmessage = function (e) {
      //   console.log(e.data);
      // };
    </script>
  </body>
</html>
